{
 "cells": [
  {
   "cell_type": "code",
   "id": "a3d37f1f692c5f41",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-11-11T11:28:06.112545Z",
     "start_time": "2024-11-11T11:28:06.097639Z"
    }
   },
   "source": [
    "# -*- coding:utf-8 -*-\n",
    "# main.py\n",
    "from sympy.abc import lamda\n",
    "\n",
    "import wordID\n",
    "pycode = wordID.open_file()\n",
    "# print(pycode)\n",
    "output = wordID.match_word(pycode)\n",
    "# type(output)\n",
    "# for i in output.keys():\n",
    "#     print(f\"({output[i]}:{i}:{[key for key,value in wordID.word_type.items() if value == i]})\")\n",
    "wordID.word_type.items()"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前文件路径:D:/01l/work/code/python/002py/wordID.py\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "dict_items([('keyword', 1), ('identifier', 2), ('unsigned', 3), ('operator', 4), ('delimiter', 5), ('escape', 6), ('unknown', 7), ('start', 8), ('comment', 9), ('isdelimiter_signal', 10)])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 5
  },
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-11-11T11:28:08.507652Z",
     "start_time": "2024-11-11T11:28:08.502979Z"
    }
   },
   "source": "[key for key,value in wordID.word_type.items() if value == 1]",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['keyword']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 6
  },
  {
   "cell_type": "code",
   "id": "c58e361e1d0d58f3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-11-11T11:28:10.378542Z",
     "start_time": "2024-11-11T11:28:10.373005Z"
    }
   },
   "source": [
    "for i in output.keys():\n",
    "    print(f\"({output[i]}:{i}:{[key for key,value in wordID.word_type.items() if value == output[i]]})\")"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2:import:['identifier'])\n",
      "(10: :['isdelimiter_signal'])\n",
      "(2:tkinter:['identifier'])\n",
      "(2:as:['identifier'])\n",
      "(2:tk:['identifier'])\n",
      "(2:from:['identifier'])\n",
      "(2:operator:['identifier'])\n",
      "(2:index:['identifier'])\n",
      "(2:filedialog:['identifier'])\n",
      "(2:boltons:['identifier'])\n",
      "(10:.:['isdelimiter_signal'])\n",
      "(2:iterutils:['identifier'])\n",
      "(2:lstrip:['identifier'])\n",
      "(2:sqlalchemy:['identifier'])\n",
      "(2:dialects:['identifier'])\n",
      "(2:mssql:['identifier'])\n",
      "(2:base:['identifier'])\n",
      "(2:wordID:['identifier'])\n",
      "(2:wordDB:['identifier'])\n",
      "(4:=:['operator'])\n",
      "(5:(:['delimiter'])\n",
      "(1:\"keyword\":['keyword'])\n",
      "(10:,:['isdelimiter_signal'])\n",
      "(1:\"identifier\":['keyword'])\n",
      "(1:\"unsigned\":['keyword'])\n",
      "(1:\"operator\":['keyword'])\n",
      "(1:\"delimiter\":['keyword'])\n",
      "(1:\"escape\":['keyword'])\n",
      "(1:\"unknown\":['keyword'])\n",
      "(1:\"start\":['keyword'])\n",
      "(1:\"comment\":['keyword'])\n",
      "(1:\"isdelimiter_signal\":['keyword'])\n",
      "(5:):['delimiter'])\n",
      "(5:{:['delimiter'])\n",
      "(5:}:['delimiter'])\n",
      "(2:for:['identifier'])\n",
      "(2:item:['identifier'])\n",
      "(2:in:['identifier'])\n",
      "(2:range:['identifier'])\n",
      "(2:len:['identifier'])\n",
      "(10:::['isdelimiter_signal'])\n",
      "(5:[:['delimiter'])\n",
      "(5:]:['delimiter'])\n",
      "(4:+:['operator'])\n",
      "(2:print:['identifier'])\n",
      "(2:comment:['identifier'])\n",
      "(1:\"\":['keyword'])\n",
      "(2:def:['identifier'])\n",
      "(2:file:['identifier'])\n",
      "(4:/:['operator'])\n",
      "(2:py:['identifier'])\n",
      "(1:\":['keyword'])\n",
      "(2:if:['identifier'])\n",
      "(2:f:['identifier'])\n",
      "(2:当前文件路径:['identifier'])\n",
      "(2:with:['identifier'])\n",
      "(2:open:['identifier'])\n",
      "(1:\"r\":['keyword'])\n",
      "(4:-:['operator'])\n",
      "(2:readlines:['identifier'])\n",
      "(2:return:['identifier'])\n",
      "(2:else:['identifier'])\n",
      "(2:line:['identifier'])\n",
      "(2:repr:['identifier'])\n",
      "(2:or:['identifier'])\n",
      "(2:isoperator:['identifier'])\n",
      "(2:continue:['identifier'])\n",
      "(2:isalpha:['identifier'])\n",
      "(1:'_':['keyword'])\n",
      "(2:isdigit:['identifier'])\n",
      "(2:isdelimiter:['identifier'])\n",
      "(1:\"Ldelimiter\":['keyword'])\n",
      "(1:\"Rdelimiter\":['keyword'])\n",
      "(1:\"\\r\\e\":['keyword'])\n",
      "(1:':['keyword'])\n",
      "(1:'':['keyword'])\n",
      "(1:\"\\r\\_\\c\\h\":['keyword'])\n",
      "(2:not:['identifier'])\n",
      "(1:\"0\":['keyword'])\n",
      "(1:\"1\":['keyword'])\n",
      "(1:\"2\":['keyword'])\n",
      "(1:\"3\":['keyword'])\n",
      "(1:\"4\":['keyword'])\n",
      "(1:\"5\":['keyword'])\n",
      "(1:\"6\":['keyword'])\n",
      "(1:\"7\":['keyword'])\n",
      "(1:\"8\":['keyword'])\n",
      "(1:\"9\":['keyword'])\n",
      "(2:target:['identifier'])\n",
      "(2:i:['identifier'])\n",
      "(2:False:['identifier'])\n",
      "(1:\"\\ \\[\":['keyword'])\n",
      "(1:\"\\\"\\,\\\":['keyword'])\n",
      "(2:and:['identifier'])\n",
      "(2:iskeyword:['identifier'])\n",
      "(1:\"string\":['keyword'])\n",
      "(2:当前单词缓冲区:['identifier'])\n"
     ]
    }
   ],
   "execution_count": 7
  },
  {
   "cell_type": "code",
   "id": "b354b480-83e0-422f-afcf-7bf57c0b3861",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-11-10T09:09:22.046897Z",
     "start_time": "2024-11-10T09:09:22.044453Z"
    }
   },
   "source": [],
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "5c6a3616ec12fdb6"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
